<template>
    <!--有时max值还未获取到会显示underfind，但终归会拿到这个值，这时我们可以使用 watch 属性来监听父组件传递过来的 max 值。-->
    <div class="mui-numbox" data-numbox-min='1' :data-numbox-min='max'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" value="1" ref="number" @change="countChanged"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from '../../assets/mui/js/mui.js'
    export default {
        name: "goodsInfo_numbox",
        mounted() {
            mui('.mui-numbox').numbox();
        },
        methods:{
            countChanged(){
                this.$emit("buyNo",parseInt(this.$refs.number.value));
            }
        },
        props:[
            "max"
        ],
        watch:{
            // 属性监听
            'max': function (newVal,oldVal) {
                mui('.mui-numbox').numbox().setOption('max',newVal);
            }
        }
    }
</script>

<style lang="scss" scoped>

</style>
